package menupopupplugin2.popup.actions;

import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;

import databaseTransaction.Table;

public class OverideWizard extends CustomWizardPage {
	protected Table table;
	private Composite container;
	protected Button overide;
	protected Button merge;


	public OverideWizard(Table table) {
		super("Overide or Merge Table");
		this.table = table;
		setTitle("Overide or Merge Table");
		setDescription("Tabel " + table.getName() + "already exist.\n Do you want to overide current table?");
	}

	@Override
	public void createControl(Composite parent) {
		container = new Composite(parent, SWT.NULL);
		GridLayout layout = new GridLayout();
		container.setLayout(layout);
		layout.numColumns = 1;

		RdSelectionListener rdSelectionListener = new RdSelectionListener();
		overide = new Button(container, SWT.RADIO);
		overide.setText("Overide current table");
		overide.addSelectionListener(rdSelectionListener);

		merge = new Button(container, SWT.RADIO);
		merge.setText("Add new fields to current table and overide persistent");
		merge.addSelectionListener(rdSelectionListener);
		// Required to avoid an error in the system

		setControl(container);
		setPageComplete(true);
	}

	private class RdSelectionListener implements SelectionListener {

		@Override
		public void widgetDefaultSelected(SelectionEvent arg0) {

		}

		@Override
		public void widgetSelected(SelectionEvent arg0) {
			setPageComplete(true);
				
		}

	}

	@Override
	public boolean isFinish() {
		return false;
	}


}